package com.zmzncs.lmtc.module.customer.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zmzncs.lmtc.common.pojo.PageVO;
import com.zmzncs.lmtc.common.pojo.Rest;
import com.zmzncs.lmtc.common.util.JsonUtil;
import com.zmzncs.lmtc.common.util.RestUtil;
import com.zmzncs.lmtc.module.customer.pojo.card_record_park.CardRecordParkDTO;
import com.zmzncs.lmtc.module.customer.pojo.card_record_park.CardRecordParkVO;
import com.zmzncs.lmtc.module.customer.service.CardRecordParkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 任建波
 * @since 2020-09-09
 */
@Api(tags = "购买记录关联的停车场")
@RestController
@RequestMapping("/customer/card-record-park")
@Validated
public class CardRecordParkController {

    @Autowired
    CardRecordParkService cardRecordParkService;

    @ApiOperation(value = "获取时长卡购买记录关联的停车场")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
            @ApiImplicitParam(paramType="query", name = "currentPage", value = "页码", required = true),
            @ApiImplicitParam(paramType="query", name = "pageSize", value = "每页记录数", required = true),
            @ApiImplicitParam(paramType = "query", name = "cardRecordId", value = "购买记录id", required = true),
            @ApiImplicitParam(paramType = "query", name = "keyword", value = "停车场名称"),
    })
    @GetMapping(value = "/getDurationCardRecord")
    public Rest<PageVO<CardRecordParkVO>> getDurationCardRecordParkList(@NotNull Integer currentPage, @NotNull Integer pageSize, @NotNull Integer cardRecordId, String keyword) {
        IPage<CardRecordParkDTO> cardRecordParkDTOPage = cardRecordParkService.getDurationCardRecordParkList(new Page(currentPage, pageSize), cardRecordId, keyword);

        PageVO<CardRecordParkVO> cardRecordParkVOPage = JsonUtil.pageTransform(cardRecordParkDTOPage, CardRecordParkVO.class);

        return RestUtil.success(cardRecordParkVOPage);
    }

}

